import request from '../utils/request'
// 登录
export let loginlink = (name, pass) => {
    return request({
        url: "/admin/login",
        method: "POST",
        data: {
            name,
            pass
        }

    })
}

// 顶部搜索
export let searchlink = (key) => {
    return request({
        url: "/menu/getMenuList",
        method: "GET",
        params: {
            key
        }

    })
}

// 新增用户
export let useraddlink = (obj) => {
    return request({
        url: "/admin/update",
        method: "POST",
        data: {
            adminAge: obj.adminAge,
            adminName: obj.adminName,
            adminSex: obj.adminSex,
            adminWorkYears: obj.adminWorkYears,
            password: obj.password,
            role: obj.role,
            rolecode: obj.rolecode,
            userName: obj.userName
        }
      
    })
}

// 查看全部
export let adminfindall = () => {
    return request({
        url: "/admin/findAll",
        method: "GET"

    })
}

//  角色码查询/admin/findCode
export let adminfindcode = (userName) => {
    return request({
        url: "/admin/findCode",
        method: "GET",
        params:{
            userName
        }

    })
}
//  账号查询/admin/findCode
export let adminnamefind = (adminName) => {
    return request({
        url: "/admin/findOne",
        method: "GET",
        params:{
            adminName
        }

    })
}







// json-server
export let loginjson = (admin_name, password) => {
    return request({
        url: " http://localhost:3000/login",
        method: "GET",
        params: {
            admin_name,
            password
        }

    })
}
export let checkuserjson = () => {
    return request({
        url: " http://localhost:3000/admin",
        method: "GET"

    })
}

export let adduserjson = (obj) => {
    return request({
        url: " http://localhost:3000/admin",
        method: "POST",
        data: {
            obj
        }

    })
}








